package cn.com.bean;

import org.springframework.context.SmartLifecycle;
import org.springframework.stereotype.Component;

@Component
public class MySmartLifecycle implements SmartLifecycle {



	private boolean isRunning = false;

	@Override
	public boolean isAutoStartup() {
		System.out.println("【MySmartLifecycle】调用<bean>的isAutoStartup属性指定的初始化方法");
		return true;
	}

	@Override
	public void stop(Runnable callback) {
		System.out.println("【MySmartLifecycle】调用<bean>的stop属性指定的初始化方法");
	}

	@Override
	public void start() {
		//isRunning为false才会执行
		System.out.println("【MySmartLifecycle】调用<bean>的start属性指定的初始化方法");
		isRunning = true;
	}

	@Override
	public void stop() {
		System.out.println("【MySmartLifecycle】调用<bean>的stop属性指定的初始化方法");
	}

	@Override
	public boolean isRunning() {
		return isRunning;
	}

	@Override
	public int getPhase() {
		return 1;
	}
}
